package co.th.bjc.md.dbonline.control;

import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.List;

import org.apache.log4j.Logger;

import co.th.bjc.md.dbonline.bean.BrandDBOnlineBean;
import co.th.bjc.md.helper.BrandHelper;
import co.th.bjc.md.model.Brand;

public class BrandDBOnlineControl {

	private static Logger _log = Logger.getLogger(BrandDBOnlineControl.class);
	
	public List<BrandDBOnlineBean> findBrandByCategory(BigDecimal category){
		List<BrandDBOnlineBean> list = new ArrayList<BrandDBOnlineBean>(0);
		try {
			List<Brand> listBrand = new BrandHelper().findBrandByCategory(category);
			for (Brand brand : listBrand) {
				BrandDBOnlineBean bean = new BrandDBOnlineBean();
				bean.setBrandCode(brand.getBrandCode());
				bean.setBrandNameTh(brand.getBrandNameTh());
				bean.setBrandNameEn(brand.getBrandNameEn());
				list.add(bean);
			}
		} catch (Exception ex) {
			_log.error("Exception : " + ex.getMessage());
			ex.printStackTrace();
		}
		return list;
	}
}
